#ifndef COMMON_SMS_H
#define COMMON_SMS_H

// 启用 OpenSSL 支持
#define CPPHTTPLIB_OPENSSL_SUPPORT

#include <memory>
#include <string>

#include "httplib.h"

namespace chat {
/**
 * @brief 使用spug向手机发送短信
 */
class SpugSMSCodeSender {
   public:
    SpugSMSCodeSender(const std::string& api_key)
        : client_(std::make_shared<httplib::SSLClient>("push.spug.cc")),
          api_key_(api_key) {}

    /**
     * @brief 向指定手机发送短信
     * @param code[in]: 短信验证码，只能为数字
     * @param phone[in]: 接收的手机号
     */
    bool send(const std::string& code, const std::string& phone);

   private:
    std::shared_ptr<httplib::SSLClient> client_ = nullptr;
    const std::string api_key_;  // 6dwezjV9PMmgLkRG
};

using SpugSMSCodeSenderPtr = std::shared_ptr<SpugSMSCodeSender>;
}  // namespace chat

#endif  // COMMON_SMS_H